package com.jilian.mydemo.modul.main.viewmodel;

import android.arch.lifecycle.LiveData;

import com.jilian.mydemo.base.BaseDto;
import com.jilian.mydemo.base.BaseViewModel;
import com.jilian.mydemo.common.dto.MsgListDto;
import com.jilian.mydemo.common.vo.AppNoticeVo;
import com.jilian.mydemo.factory.Factoty;
import com.jilian.mydemo.modul.user.repository.UserRepository;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
public class MainViewModel extends BaseViewModel {
    /**
     * 消息列表
     */
    private LiveData<BaseDto<MsgListDto>> msgliveData;
    /**
     * 消息读接口
     */
    private LiveData<BaseDto> readliveData;


    public LiveData<BaseDto<MsgListDto>> getMsgliveData() {
        return msgliveData;
    }

    public LiveData<BaseDto> getReadliveData() {
        return readliveData;
    }

    /**
     * 查询消息列表
     * @param pageNum
     * @param pageSize
     * @param type 1 系统消息 2 通知消息
     */
    public void getMsgList(Integer pageNum,Integer pageSize,Integer type){
        AppNoticeVo vo = new AppNoticeVo();
        vo.setPageNum(pageNum);
        vo.setPageSize(pageSize);
        vo.setType(type);
        msgliveData =  Factoty.getRepository(UserRepository.class).query(vo);
    }
    /**
     * 消息读接口
     * @param id
     * @return
     */
    public void read(Long id){
        AppNoticeVo vo = new AppNoticeVo();
        vo.setId(id);
        readliveData =  Factoty.getRepository(UserRepository.class).read(vo);
    }
}
